<?php

namespace app\admin\controller\xcrontab;

use addons\xcrontab\library\CheckInstallTrait;
use addons\xcrontab\library\RunStatus;
use app\common\controller\Backend;

class Info extends Backend
{

    use CheckInstallTrait;
    public function _initialize()
    {
        parent::_initialize();
        $this->installOk();
    }

    public function index()
    {
        $config = get_addon_config('xcrontab');
        if($time = RunStatus::lastRunTime()) {
            $this->assign('lastTime', date('Y-m-d H:i:s',$time));
        } else {
            $this->assign('lastTime', '');
        }
        $this->assign('active', $config['active']);
        $this->assign('timeout', $config['timeout']);
        if($config['active']==0) {
            RunStatus::clean();
        }
        return $this->view->fetch();
    }
}
